//
//  GGBtnsView.m
//  Gunterapple
//
//  Created by 热带雨林 on 2020/4/3.
//  Copyright © 2020 热带雨林. All rights reserved.
//

#import "GGBtnsView.h"
#import "GGAddtion.h"
@interface GGBtnsView()
@property (nonatomic, weak)UIButton *picBtn;
@property (nonatomic, weak)UIButton *favreBtn;
@property (nonatomic, weak)UIButton *vipBtn;

@end
@implementation GGBtnsView

- (instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        [self setUI];
    }
    return self;
}
- (void)setUI{
    CGFloat wight = CGRectGetWidth(self.frame)/3;
    CGFloat height = CGRectGetHeight(self.frame);
    //注意此处设置的frame是没有用的
    UIButton *picBtn = [UIButton initButtonWithFrame:CGRectZero withImage:[UIImage imageNamed:@"mine_album"] withTitle:@"相册" withTitleColor:[UIColor blackColor] withFont:[UIFont systemFontOfSize:15] withSpace:5 withType:GD_Left withTarget:self withAction:@selector(clickBtn:)];
    self.picBtn = picBtn;
    self.picBtn.tag = btnPic;
    //设置btn内部图片与文字的对齐方式
    self.picBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [self addSubview:picBtn];
    
    UIButton *favreBtn = [UIButton initButtonWithFrame:CGRectZero withImage:[UIImage imageNamed:@"mine_favorite"] withTitle:@"收藏" withTitleColor:[UIColor blackColor] withFont:[UIFont systemFontOfSize:15] withSpace:5 withType:GD_Left withTarget:self withAction:@selector(clickBtn:)];
    self.favreBtn = favreBtn;
    self.favreBtn.tag = btnFa;
    self.favreBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [self addSubview:favreBtn];
    
    UIButton *vipBtn = [UIButton initButtonWithFrame:CGRectZero withImage:[UIImage imageNamed:@"mine_vip"] withTitle:@"会员中心" withTitleColor:[UIColor blackColor] withFont:[UIFont systemFontOfSize:15] withSpace:5 withType:GD_Left withTarget:self withAction:@selector(clickBtn:)];
    self.vipBtn = vipBtn;
    self.vipBtn.tag = btnVip;
    self.vipBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [self addSubview:vipBtn];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    //子视图之间的间距
//    [self.subviews mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:8 leadSpacing:0 tailSpacing:50];
    //子视图的长度
    [self.subviews mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedItemLength:100 leadSpacing:0 tailSpacing:90];
    [self.subviews mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.height.mas_equalTo(32);
    }];
}
- (void)clickBtn:(UIButton *)sender{
    if([self.delegate respondsToSelector:@selector(btnViwesWithType:)]){
        [self.delegate btnViwesWithType:sender.tag];
    }
}

@end
